home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / GNUUCP_2 / SOURCE / SYSDEP.CPM < prev    next >
Text File  |  1989-07-31  |  3KB  |  155 lines

  1. /*
  2.  * @(#)sysdep.cpm 1.3 87/09/23    Copyright 1987 Free Software Foundation, Inc.
  3.  *
  4.  * Copying and use of this program are controlled by the terms of the
  5.  * GNU Emacs General Public License.
  6.  */
  7.  
  8. #ifndef lint
  9. char sysdep_version[] = "@(#)sysdep.cpm gnuucp Version hoptoad-1.3";
  10. #endif
  11.  
  12. /*
  13.  * Split out of uuslave.c by John Gilmore, 8 August 1987.
  14.  */
  15.  
  16. #include "includes.h"
  17. #include "uucp.h"
  18. #include "sysdep.h"
  19.  
  20. /* CP/M-80 */
  21. #include <stdio.h>
  22. #include <ctype.h>
  23. #include <fcntl.h>
  24.  
  25. #define    NAMESIZE    50        /* No directories... */
  26.  
  27. /* Our variables */
  28.  
  29. int    fdtty;                /* File descriptor for tty line */
  30.  
  31. void sigint();                /* Forward declaration */
  32.  
  33. /*
  34.  * Open the serial line for an incoming call.
  35.  * Argument of NULL or empty string means stdin.
  36.  */
  37. void
  38. openline(ttynam)
  39.     char    *ttynam;
  40. {
  41.     int ontheline = !(ttynam && ttynam[0]);    /* FIXME, this is garbage */
  42.  
  43. #ifdef COMPORT
  44.     if ((get_msr() & CD) == 0)
  45.       ontheline = 0;
  46.     else
  47.          ontheline = 1;
  48.  
  49.     if (!ontheline){
  50.         sleep(2);       /* take two to wait for the modem to
  51.                 reset in case this programme is 
  52.                  recycled. */
  53.  
  54.     printf("uucico : master mode\n");
  55.     set_tty(COMM1, B1200, CS8, MENBL);
  56.     printf("uucico : initializing modem.\n");
  57.     xwrite(fdtty, hayesinit, sizeof(hayesinit)-1);
  58.     }
  59. #endif
  60.  
  61.     /* FIXME, we should implement ontheline here */
  62.     sioinit();
  63. }
  64.  
  65. /*
  66.  * Basement level I/O routines
  67.  *
  68.  * xwrite() writes a character string to the serial port
  69.  * xgetc() returns a character from the serial port, or an EOF for timeout.
  70.  * sigint() restores the state of the serial port on exit.
  71.  */
  72.  
  73. #define    abort()    exit(1)
  74. extern xgetc(), xwrite(), sioinit();
  75.  
  76. void
  77. sigint()
  78. {
  79.     /* Restore terminal settings on dialout line */
  80.     exit(0);
  81. }
  82.  
  83.  
  84. /* CP/M and MSDOS and ST need these routines.  Probably should use
  85.  * the new names, but for now...
  86.  */
  87. bzero(s, cnt)
  88. register char    *s;
  89. register int    cnt;
  90. {
  91.     register int    i;
  92.     for (i = 0; i < cnt; i++) {
  93.         *s++ = '\0';
  94.     }
  95. }
  96.  
  97. bcopy(from, to, cnt)
  98. register char    *from;
  99. register char    *to;
  100. register int    cnt;
  101. {
  102.     register int    i;
  103.     for (i = 0; i < cnt; i++) {
  104.         *to++ = *from++;
  105.     }
  106. }
  107.  
  108.  
  109. /*
  110.  * Create a temporary file name for receiving a file into.
  111.  * "name" is the name we will actually eventually want to use for the file.
  112.  * We currently ignore it, but some OS's that can't move files around
  113.  * easily might want to e.g. put the temp file into the same directory
  114.  * that this file is going into.
  115.  *
  116.  * FIXME:
  117.  * This interface should be able to return a "possible" filename, and
  118.  * be re-called if the name is already in use, to get another.
  119.  * This avoids checking here whether the name is good -- saving system calls.
  120.  */
  121. char *
  122. temp_filename(name)
  123.     register char *name;
  124. {
  125.     static char tname[NAMESIZE];
  126.  
  127. #ifdef DEBUG
  128.     printf("Using temp file %s\n", tname);
  129. #endif
  130.     return tname;
  131. }
  132.  
  133.  
  134. /*
  135.  * Transform a filename from a uucp packet (in Unix format) into a local
  136.  * filename that will work in the local file system.
  137.  */
  138. char *
  139. munge_filename(name)
  140.     register char *name;
  141. {
  142.     register char *p;
  143.  
  144. #ifdef DEBUG
  145.     printf("Munge_filename  input: %s\n", name);
  146. #endif
  147.  
  148.     for (p = name + strlen(name); p != name && *(p-1) != '/'; p--) ;
  149.  
  150. #ifdef DEBUG
  151.     printf("Munge_filename output: %s\n", p);
  152. #endif
  153.     return p;
  154. }
  155.